<template>
	<view>
		<view :style="{'height':mHeight+'px'}">
			<web-view class="webView" :style="{height:'100%',width:'100%',border:'none'}" :src="src"
				:fullscreen="false"></web-view>
		</view>

		<view class="wd100 dis-flex flex-align-center pos-fix" style="bottom: 0;left: 0;" v-if="detailInfo.status == 2">
			<view class="dis-flex flex-align-center px16 wd100" style="padding-top: 10px;padding-bottom: 10px;">
				<button class="c-fff wd100"
					style="background: #5B769F;width: 90%;margin: auto;line-height:45px;font-size:32rpx;border-radius:10rpx;"
					@tap="goSign1" v-if="detailInfo.sign_type==2 && !yingzhang">去印章</button>
				<button class="c-fff wd100"
					style="background: #4A94E6;width: 90%;margin: auto;line-height:45px;font-size:32rpx;border-radius:10rpx;"
					@tap="goSign" v-else>签名</button>
			</view>
		</view>
		<view class="wd100 dis-flex flex-align-center pos-fix" style="bottom: 0;left: 0;" v-else-if="detailInfo.qzimg">
			<image style="width: 750rpx;height: 65px;" :src="detailInfo.qzimg" mode=""
				@tap="showImage(detailInfo.qzimg)"></image>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		computed: {
			...mapState(['refreshOrder']),
		},
		data() {
			return {
				id: '',
				mHeight: 1000,
				detailInfo: {},
				src: '',
				yingzhang:"",
			}
		},

		watch: {
			refreshOrder(val, old) { //刷新订单列表
				this.getContractDetail();
			}
		},

		onLoad(option) {
			this.id = option.id || '';
			this.mHeight = uni.getSystemInfoSync().windowHeight;
			this.getContractDetail();
			uni.$on('yingzhang',data=>{
				this.yingzhang = data
			})
		},

		methods: {

			getContractDetail() {
				this.$http.post(this.$config.UrlGetContractDetail, {
					id: this.id
				}, {
					log: true,
					header: {
						'content-type': 'application/json'
					}
				}).then((res) => {
					if (res.code == 1) {
						this.detailInfo = res.data || {};
						if (res.data?.status == 2 || this.detailInfo.qzimg) {
							this.mHeight = uni.getSystemInfoSync().windowHeight - 65;
						} else {
							this.mHeight = uni.getSystemInfoSync().windowHeight;
						}
						if (this.detailInfo.qzimg) this.detailInfo.qzimg = this.$store.state.host + this.detailInfo
							.qzimg;
						this.src = "https://view.xdocin.com/view?src=" + encodeURIComponent(
							`${this.$store.state.host}${res?.data?.file}`);
					} else this.$api.toast(res.msg)
				})
			},

			goSign() {
				this.$api.openWindow(`/pages/center/signature?id=${this.id}&src=${this.yingzhang}`);
			},
			goSign1(){
				this.$api.openWindow(`/pages/center/signature1?id=${this.id}`);
			},
			showImage(url) {
				uni.previewImage({
					current: 0,
					urls: [url],
				})
			},
		}
	}
</script>

<style>

</style>